﻿using UnityEngine;
using System.Collections;

public class PlayerBirds : MonoBehaviour 
{
	public static int m_speed = 20;
	Vector3 m_flyDirection;
	Transform m_transform;

    void Start()
    {
		m_transform= this.transform;
		InvokeRepeating("CheckDestroy" , 2.0f , 1f);
    }

    void Update()
    {
        if (!GameManager.IsPlaying())
            return;

		m_transform.Translate(m_flyDirection * m_speed * Time.deltaTime , Space.World);
		
        
    }

	//设置飞行的方向向量
	public void SetFlyDirection(Vector3 v3_Direction)
	{
		m_flyDirection = v3_Direction;
		
		return;
	}


	protected void CheckDestroy()
	{
		//超出可视范围
 		if(m_transform.position.x >= GameManager.screenBorder.rightBorder 
			|| m_transform.position.x <=GameManager.screenBorder.leftBorder 
			|| m_transform.position.y > GameManager.screenBorder.upBorder 
			|| m_transform.position.y < GameManager.screenBorder.downBorder )
			Destroy(this.gameObject);
	}

	public void DestroyMe()
	{
		Destroy(this.gameObject);
	}

	

}
